﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
/// <summary>
/// get 的摘要说明
/// </summary>
public class get
{
	public get()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
	}
    public static void insertwebjianzhi(string strid,string name,string worktime,string tel,string email,string school,string sex,string photo,string time,string workjingyan)
    {
        try
        {
            SqlConnection con = ConDB.GetOpen();
            string sql = "insert into webjianzhi values('"+strid+"','"+name+"','"+worktime+"','"+tel+"','"+email+"','"+school+"','"+sex+"','"+photo+"','"+time+"','"+workjingyan+"')";
            SqlCommand cmd = new SqlCommand(sql,con);
            cmd.ExecuteNonQuery();
        }
        catch (SqlException e)
        { }
        finally
        {
            ConDB.Close();
        }
    }
    public static void insertcomwebjianzhi(string strid, string name, string tel, string link,string type, int num, string apply, string usetime, string email)
    {
        try
        {
            SqlConnection con = ConDB.GetOpen();
            string sql = "insert into comparttimework values('" + strid + "','" + name + "','" + tel + "','" + link + "','" + type + "','" + num + "','" + apply + "','" + usetime + "','" + email + "')";
            SqlCommand cmd = new SqlCommand(sql, con);
            cmd.ExecuteNonQuery();
        }
        catch (SqlException e)
        { }
        finally
        {
            ConDB.Close();
        }
    }
    public static string getmaxwebjianzhiid()
    {
        try
        {
            SqlConnection con = ConDB.GetOpen();
            string strsql = "select max(id) from webjianzhi";
            SqlCommand cmd = new SqlCommand(strsql,con);
            string temp = cmd.ExecuteScalar().ToString();
            return temp;      
        }
        catch (SqlException e)
        {
            return "";
        }
        finally
        {
            ConDB.Close();
        }
    }
    public static string getmaxcomwebjianzhiid()
    {
        try
        {
            SqlConnection con = ConDB.GetOpen();
            string strsql = "select max(comid) from comparttimework";
            SqlCommand cmd = new SqlCommand(strsql, con);
            string temp = cmd.ExecuteScalar().ToString();
            return temp;
        }
        catch (SqlException e)
        {
            return "";
        }
        finally
        {
            ConDB.Close();
        }
    }
    public void deleteapply(int id)
    {
        try
        {
            SqlConnection con = ConDB.GetOpen();
            string sql = "delete from tb_jobapply where cwid=" + id + "";
            SqlCommand cmd = new SqlCommand(sql, con);
            cmd.ExecuteNonQuery();
        }
        catch (SqlException e)
        { }
        finally
        {
            ConDB.Close();
        }
    }
    /// <summary>
    /// 获得兼职互动的信息
    /// </summary>
    /// <returns></returns>
    public static DataSet getjianzhihudonginfo()
    {
        SqlConnection con = ConDB.GetOpen();
        SqlCommand cmd = new SqlCommand("select * from jianzhihudong",con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        return ds;
    }
    /// <summary>
    /// 删除指定的兼职互动信息
    /// </summary>
    /// <param name="id"></param>
    public static void deljianzhihudong(int id)
    {
        SqlConnection con = ConDB.GetOpen();
        SqlCommand cmd = new SqlCommand("delete from jianzhihudong where id="+id+"",con);
        cmd.ExecuteNonQuery();
        con.Close();
    }
    public static void insertjianzhihudong(string name,string p,string n,string t)
    {
        SqlConnection con = ConDB.GetOpen();
        SqlCommand cmd = new SqlCommand("insert into jianzhihudong values('"+name+"','"+p+"','"+n+"','"+t+"')",con);
        cmd.ExecuteNonQuery();
        con.Close();
    }
    /// <summary>
    /// 删除web兼职里的人
    /// </summary>
    /// <returns></returns>
    public static void delwebjianzhi(string strid)
    {
        try
        {
            SqlConnection con = ConDB.GetOpen();
            SqlCommand cmd = new SqlCommand("delete from webjianzhi where id='"+strid+"'",con);
            cmd.ExecuteNonQuery();
        }
        catch (SqlException e)
        { }
        finally
        {
            ConDB.Close();
        }
    }
    public static void delcomwebjianzhi(string strid)
    {
        try
        {
            SqlConnection con = ConDB.GetOpen();
            SqlCommand cmd = new SqlCommand("delete from comparttimework where comid='" + strid + "'", con);
            cmd.ExecuteNonQuery();
        }
        catch (SqlException e)
        { }
        finally
        {
            ConDB.Close();
        }
    }
    /// <summary>
    /// 查询web兼职人
    /// </summary>

    public static DataSet getwebjianzhiinfo()
    {
        SqlConnection con = ConDB.GetOpen();
        SqlCommand cmd = new SqlCommand("select * from webjianzhi",con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        return ds;
    }
    public static DataSet getcomwebjianzhiinfo()
    {
        SqlConnection con = ConDB.GetOpen();
        SqlCommand cmd = new SqlCommand("select * from comparttimework", con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        return ds;
    }
    /// <summary>
    /// 修改web兼职里的人
    /// </summary>
    /// <returns></returns>
    public static void updatejianzhi(string id,string name,string worktime,string tel,string email,string school,string sex,string photo,string applytime,string workjingyan)
    {
        try
        {
            SqlConnection con = ConDB.GetOpen();
            string sql = "update webjianzhi set name='"+name+"',worktime='"+worktime+"',tel='"+tel+"',email='"+email+"',school='"+school+"',sex='"+sex+"',photo='"+photo+"',applytime='"+applytime+"',workjingyan='"+workjingyan+"' where id='"+id+"'";
            SqlCommand cmd = new SqlCommand(sql, con);
            cmd.ExecuteNonQuery();
        }
        catch (SqlException e) { }
        finally
        {
            ConDB.Close();
        }
    }
    public static void updatecomwebjianzhi(string id, string name, string tel, string link, string type, int num, string applytime, string usetime,string email)
    {
        try
        {
            SqlConnection con = ConDB.GetOpen();
            string sql = "update comparttimework set comname='" + name + "',comtel='"+tel+"',linkman='"+link+"',type='"+type+"',num="+num+",applytime='"+applytime+"',usetime='"+usetime+"',email='"+email+"' where comid='" + id + "'";
            SqlCommand cmd = new SqlCommand(sql, con);
            cmd.ExecuteNonQuery();
        }
        catch (SqlException e) { }
        finally
        {
            ConDB.Close();
        }
    }
    public Boolean jobapplyinfo(int id)
    {
        try
        {
            SqlConnection con = ConDB.GetOpen();
            string str = "select count(*) from tb_comwant where cwid=" + id + "";
            SqlCommand cmd = new SqlCommand(str, con);
            int i = Convert.ToInt32(cmd.ExecuteScalar());
            if (i == 0)
                return false;
            else
                return true;
            }
        catch (SqlException e)
        {
            return false;
        }
      
        
        finally
        {
            ConDB.Close();
        }
    }
    public DataSet getrencaikuadmin()
    {
        DataSet ds = null;
        try
        {
            SqlConnection con = ConDB.GetOpen();
           // string sql = "SELECT upersoninfo.upersonname, upersoninfo.upersonadd, upersoninfo.upersontel, upersoninfo.upersonsex, upersoninfo.upersonage, upersoninfo.uhandletime, upersoninfo.utime,univercityunitclass.uuname,upersoninfo.pname  FROM  univercityunitclass,upersoninfo WHERE univercityunitclass.uuid=upersoninfo.uuid";
            string sql = "SELECT * FROM  univercityunitclass,upersoninfo WHERE univercityunitclass.uuid=upersoninfo.uuid";
            SqlDataAdapter da = new SqlDataAdapter(sql,con);
            ds = new DataSet();
            da.Fill(ds);
            
            return ds;
        }
        catch (SqlException e)
        {
            return null;
        }
            
        finally
        {
            ConDB.Close();
        }
    }
    public string getnamebyid(string id)
    {
        SqlConnection con = ConDB.GetOpen();
        SqlCommand cmd = new SqlCommand("select pname from tb_person where pid='"+id+"'",con);
        string str = cmd.ExecuteScalar().ToString();
        return str;
    }
    public void deletezhaopinhui(int zhaopinhuiid)
    {
        try
        {
            SqlConnection con = ConDB.GetOpen();
            string sql = "DELETE FROM [WantMeetInfo] WHERE [wmiid] =" + zhaopinhuiid + "";
            SqlCommand cmd = new SqlCommand(sql, con);
            cmd.ExecuteNonQuery();
        }
        catch (SqlException e)
        { }
        finally
        {
            ConDB.Close();
        }
    }
    public DataSet getupersoninfo(string strname)
    {
        DataSet ds = null;
        try
        {
            SqlConnection con = ConDB.GetOpen();
            string sql = "select upersonid,upersonname,upersonadd,upersontel,upersonsex,upersonage,uuname,uhandletime,utime from upersoninfo,univercityunitclass where upersoninfo.uuid=univercityunitclass.uuid and pname='"+strname+"'";
            SqlDataAdapter da = new SqlDataAdapter(sql, con);
            ds = new DataSet();
            da.Fill(ds);
        }
        catch (SqlException e)
        {
         
        }
        finally
        {
            ConDB.Close();
        }
        return ds;
    }
    public DataSet getvipinfo()
    {
        DataSet ds = new DataSet();
        try
        {
            SqlConnection con = ConDB.GetOpen();
            string sql = "select cpid,cpname from tb_company where isvip='是'";

            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = new SqlCommand();
            da.SelectCommand.Connection = con;
            da.SelectCommand.CommandText = sql;
           
            da.Fill(ds,"vip");
            
        }
        catch (Exception ee)
        {
            Console.Write(ee.Message);
        }
        return ds;
    }
    public DataSet getschoolclass()
    {
        DataSet ds = null;
        try
        {
            SqlConnection con = ConDB.GetOpen();
            string sql = "select * from univercityunitclass";
            SqlDataAdapter da = new SqlDataAdapter(sql,con);
            ds = new DataSet();
            da.Fill(ds,"tb_univercityunitclass");
        }
        catch (SqlException e)
        {

        }
        finally
        {
            ConDB.Close();
        }
        return ds;
    }
    public DataSet getrencaisousuo(string strkey)
    {
        DataSet ds = new DataSet();
        try
        {
            SqlConnection con = ConDB.GetOpen();
            SqlDataAdapter da = new SqlDataAdapter(strkey, con);
            da.Fill(ds, "tb_person");
        }
        catch (SqlException e)
        {
            return null;
        }
        finally
        {
            ConDB.Close();
        }
        return ds;
    }
    public DataSet getSchool()
    {
        DataSet ds = new DataSet();
        try
        {
            SqlConnection con = ConDB.GetOpen();
            SqlDataAdapter da = new SqlDataAdapter("select * from univercityunitclass", con);
            da.Fill(ds, "univercityunitclass");
        }
        catch (SqlException e)
        {
            return null;
        }
        finally
        {
            ConDB.Close();
        }
        return ds;
    
    }
    public DataSet shousuo(string sql)
    {
        DataSet ds = new DataSet();
        try
        {
            SqlConnection con = ConDB.GetOpen();
            SqlDataAdapter da = new SqlDataAdapter(sql, con);
            da.Fill(ds, "upersoninfo");
        }
        catch (SqlException e)
        {
            return null;
        }
        finally
        {
            ConDB.Close();
        }
        return ds;
    }

    public DataSet getrencaiku()
    {
        DataSet ds = new DataSet();
        try
        {
            SqlConnection con = ConDB.GetOpen();
            string sql = "select pid,pname,psex,page,pzy,pmz,pzzface,padd,phouseholder,ptel,pemail,pschool,pknowledge from tb_person order by page";
            SqlDataAdapter da = new SqlDataAdapter(sql, con);
            da.Fill(ds, "tb_person");
        }
        catch (SqlException e)
        { return null; }
        finally
        {
            ConDB.Close();
        }
        return ds;
    }
    public DataSet getupersoninfo(int id)
    {
        DataSet ds = new DataSet();
        try
        {
            SqlConnection con = ConDB.GetOpen();
            string sql = "select * from upersoninfo,univercityunitclass where upersoninfo.uuid=" + id + " and univercityunitclass.uuid=upersoninfo.uuid";
            SqlDataAdapter da = new SqlDataAdapter(sql, con);
            da.Fill(ds);
        }
        catch (SqlException e)
        { }
        finally
        {
            ConDB.Close();
        }
        return ds;
    }
    public DataSet getupersoninfo()
    {
        DataSet ds = new DataSet();
        try
        {
            SqlConnection con = ConDB.GetOpen();
            string sql = "select * from upersoninfo,univercityunitclass where univercityunitclass.uuid=upersoninfo.uuid";
            SqlDataAdapter da = new SqlDataAdapter(sql, con);
            da.Fill(ds);
        }
        catch (SqlException e)
        {
            return null;
        }
        finally
        {
            ConDB.Close();
        }
        return ds;
    }
    public string getnamesession(string id)
    {
        string strname = "";
        try
        {
            if (id==null)
            {
                return "0";
            }
            
            SqlConnection con = ConDB.GetOpen();
            string sql = "select * from tb_person where pid=" + id + "";
            SqlCommand cmd = new SqlCommand(sql, con);
            SqlDataReader dr = cmd.ExecuteReader();
            dr.Read();
            strname = dr[1].ToString();
        }
        catch (SqlException e)
        {
            return "";
        }
        finally
        {
            ConDB.Close();
        }
        return strname;

    }
    public int getschoolid(string schoolname)
    {
        int i=0;
        try
        {
            SqlConnection con = ConDB.GetOpen();
            string sql = "select uuid from univercityunitclass where uuname='"+schoolname+"'";
            SqlCommand cmd = new SqlCommand(sql,con);
            i = Convert.ToInt32(cmd.ExecuteScalar());
        }
        catch (SqlException e)
        {
            return 0;
        }
        finally
        {
            ConDB.Close();
        }
        return i;
    }
    public void deljianzhi(int id)
    {
        try
        {
            SqlConnection con = ConDB.GetOpen();
            string sql = "delete from upersoninfo where upersonid=" + id + "";
            SqlCommand cmd = new SqlCommand(sql, con);
            cmd.ExecuteNonQuery();
        }
        catch (SqlException e) { }
        finally
        {
            ConDB.Close();
        }
    }
    public void delSchool(int id)
    {
        try
        {
            SqlConnection con = ConDB.GetOpen();
            string sql = "delete from univercityunitclass where uuid=" + id + "";
            SqlCommand cmd = new SqlCommand(sql, con);
            cmd.ExecuteNonQuery();
        }
        catch (SqlException e) { }
        finally
        {
            ConDB.Close();
        }
    }
    public DataSet geteditinfo(int id)
    {
        DataSet ds = new DataSet();
        try
        {
            SqlConnection con = ConDB.GetOpen();
            string sql = "select * from upersoninfo where upersonid='" + id + "'";
            SqlDataAdapter da = new SqlDataAdapter(sql, con);
            da.Fill(ds);
        }
        catch (SqlException e) { return null; }
        finally
        {
            ConDB.Close();
        }
        return ds;

    }
    public void updateeditinfo(string name,string add,string tel,string handletime,string pname,int id)
    {
        try
        {
            SqlConnection con = ConDB.GetOpen();
            string sql = "update upersoninfo set upersonname='" + name + "',upersonadd='" + add + "',upersontel='" + tel + "', uhandletime='" + handletime + "',pname='"+pname+"' where upersonid=" + id + "";
            SqlCommand cmd = new SqlCommand(sql, con);
            cmd.ExecuteNonQuery();
        }
        catch (SqlException e) { }
        finally
        {
            ConDB.Close();
        }
    }
    public DataSet getcompanycareer(int id)
    {
        DataSet ds = new DataSet();
        try
        {
            SqlConnection con = ConDB.GetOpen();
            string sql = "select * from tb_company,tb_comwant,tb_trade,tb_jobclass where tb_company.cpid=tb_comwant.cpid and tb_trade.trid=tb_comwant.trid and tb_jobclass.jcid=tb_comwant.jcid and tb_company.cpid=" + id + "";
            SqlDataAdapter da = new SqlDataAdapter(sql, con);
            da.Fill(ds);
        }
        catch (SqlException e)
        {
            return null;
        }
        finally
        {
            ConDB.Close();
        }
        return ds;
    }

    public int getexamid()
    {
        try
        {
            SqlConnection con = ConDB.GetOpen();
            string sql = "select min(eiid) from examinfo";
            SqlCommand cmd = new SqlCommand(sql, con);
            return Convert.ToInt32(cmd.ExecuteScalar());
        }
        catch (SqlException e)
        {
            return 0;
        }
        finally
        {
            ConDB.Close();
        }

    }
   
}
